import Vue from 'vue'
import $http from 'vue-resource'
import axios from '../httpConfig/http'
// import da from 'element-ui/lib/locale/lang/da'
Vue.use($http)

// let vm = new Vue()
/**
 * define some function about http
 */
const configPath = '/api'
window.configPath = configPath
export class Utils {
  get (url) {
    return new Promise((resolve, reject) => {
      axios.get(url).then((response) => {
        console.log(response)
        resolve(response.data)
      }, function () {
        console.log('接口错误')
      })
    })
  }
  post (url, data) {
    return new Promise((resolve, reject) => {
      axios.post(url, {
        movie: JSON.stringify(data)
      }).then((response) => {
        resolve(response.data)
      }, function () {
        console.log('接口错误')
      })
    })
  }
  get2 (url, data) {
    // url = '/static/api/b.json'
    return new Promise((resolve, reject) => {
      axios.get(url).then((response) => {
        console.log(response.data)
        resolve(response.data)
      }, function () {
        console.log('接口错误')
      })
    })
  }
}
